//
//  LoginHelper.m
//  BasketballGo
//
//  Created by TonyGenius on 16/1/8.
//  Copyright © 2016年 GSH. All rights reserved.
//

#import "LoginHelper.h"
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "LoginViewController.h"


@implementation LoginHelper

//+ (id)shareManager
//{
//    static LoginHelper *loginHelper;
//    static dispatch_once_t onceToken;
//    
//    dispatch_once(&onceToken, ^{
//        loginHelper = [[LoginHelper alloc] init];
//    });
//    
//    return self;
//}

+ (void)goingToLoginView:(NSString *)cityCode andeProive:(NSString *)provice andLocation:(CLLocation *)location
{
   
    UIWindow *window = [UIApplication sharedApplication].windows[0];
    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UINavigationController *navigationVC = [storyBoard instantiateViewControllerWithIdentifier:@"Login"];
    LoginViewController *loginVC = navigationVC.viewControllers[0];
    loginVC.cityCode = cityCode;
    loginVC.provice = provice;
    loginVC.location = location;
    window.rootViewController = navigationVC;
    
}

+ (void)goingtoHomePage:(NSString *)cityCode andeProive:(NSString *)provice andLocation:(CLLocation *)location
{
    UIWindow *window = [UIApplication sharedApplication].windows[0];
    
    XMTabBarController *tabBarController = [self createTab:cityCode andProvice:provice andLocation:location];
    
    window.rootViewController = tabBarController;
    
    
    
}

+ (XMTabBarController *)createTab:(NSString *)cityCode andProvice:(NSString *)provice andLocation:(CLLocation *)location
{
    NSMutableArray *normalArray = [NSMutableArray arrayWithObjects:[UIImage imageNamed:@"tabBarGame"],[UIImage imageNamed:@"tabBarChat"],[UIImage imageNamed:@"tabBarBoard"],[UIImage imageNamed:@"tabBarPerson"], nil];
    
    NSMutableArray *selectArray = [NSMutableArray arrayWithObjects:[UIImage imageNamed:@"tabBarGameS"],[UIImage imageNamed:@"tabBarChatS"],[UIImage imageNamed:@"tabBarBoardS"], [UIImage imageNamed:@"tabBarPersonS"],nil];
    
    NSMutableArray *nameArray = [NSMutableArray arrayWithObjects:@"约球",@"聊天",@"统计",@"个人", nil];
    
    GamingViewController *gamingVC = [[GamingViewController alloc] init];
    MessageViewController *messageVC = [[MessageViewController alloc] init];
    ScoreboardViewController *scoreBoardVC = [[ScoreboardViewController alloc] init];
    PersonViewController *personVC = [[PersonViewController alloc] init];

    UINavigationController *gaming = [[UINavigationController alloc] initWithRootViewController:gamingVC];
    
    UINavigationController *message = [[UINavigationController alloc] initWithRootViewController:messageVC];
    
    UINavigationController *scoreBoard = [[UINavigationController alloc] initWithRootViewController:scoreBoardVC];
    
    UINavigationController *person = [[UINavigationController alloc] initWithRootViewController:personVC];
//
    UINavigationController *publish = [[UINavigationController alloc] initWithRootViewController:[[PublishViewController alloc] initWithNibName:@"PublishViewController" bundle:nil]];
    
    
//    XMTabBarController *tabBarController = [[XMTabBarController alloc] initWithTabBarSelectedImages:selectArray normalImages:normalArray titles:nameArray];
    
    XMTabBarController *tabBarController = [[XMTabBarController alloc] initWithTabBarSelectedImages:selectArray normalImages:normalArray titles:nameArray backgroundImage:[UIImage imageNamed:@"tabBarBG"]];
   
    tabBarController.showCenterItem = YES;
    tabBarController.centerItemImage = [UIImage imageNamed:@"tabBarPublish"];
    tabBarController.centerItemSelectImage = [UIImage imageNamed:@"tabBarPublishS"];
    
    tabBarController.viewControllers = @[gaming,message,scoreBoard,person];
   
    tabBarController.textColor = [UIColor whiteColor];
    
    
    tabBarController.xm_centerViewController = publish;
//    [tabBarController tabBarBadgeValue:10 item:1];
    
    tabBarController.cityCode = cityCode;
    tabBarController.provice = provice;
    tabBarController.location = location;
    
    return tabBarController;
}

@end
